/**
 * @description 冒泡排序
 */

Array.prototype.bubbling = function(){
     for(let i = 0 ;i < this.length -1 ; i++){
        let flag = 1   // 标志位优化
        for(let j = 0 ;j < this.length -1 - i ; j++){
              if(this[j] > this[j+1]){
                  let a =this[j];
                  this[j] = this[j+1];
                  this[j+1] = a
                  flag = 0;
              }   
       }    
       if(flag == 1) break;
     }
}

let arr = [1,2,50,3,5,44,0,-4];
arr.bubbling()
console.log(arr)